/*
 * @Author: szx
 * @Date: 2022-05-21 14:34:54
 * @LastEditTime: 2022-05-21 14:53:36
 * @Description:
 * @FilePath: \leetcode\面试题\05\08\08.js
 */
/**
 * @param {number} length
 * @param {number} w
 * @param {number} x1
 * @param {number} x2
 * @param {number} y
 * @return {number[]}
 */
/**
 * @param {number} length
 * @param {number} w
 * @param {number} x1
 * @param {number} x2
 * @param {number} y
 * @return {number[]}
 */
var drawLine = function (length, w, x1, x2, y) {
    const res = [];
    const width = length * 32;
    let sum = 0;
    const left = y * w + x1;
    const right = y * w + x2;
    for (let i = 0; i < width; ++i) {
        sum <<= 1;
        if (left <= i && i <= right) {
            sum += 1;
        }
        if ((i + 1) % 32 === 0) {
            res.push(sum);
            sum = 0;
        }
    }
    return res;
};
drawLine();
